/*global Float32Array */
(function () {
    'use strict';
    var gl, fs, vs, mvpMatrix, triangle, mesh, p;

    gl = new NOOGL.Canvas({
        width: 640,
        height: 480
    });
    gl.appendTo(document.body);

    fs = gl.createShaderFromScript(document.getElementById('fragment-shader'));
    vs = gl.createShaderFromScript(document.getElementById('vertex-shader'));

    p = gl.createProgram(vs, fs);
    p.use();
    // IDEA: projMatrix = perspective(fov, ar, far); -> PerspectiveCamera
    mvpMatrix = new Float32Array([
        2.5 / 640 * 480, 0, 0, 0,
        0, 2.5, 0, 0,
        0, 0, -1, -1,
        0, 0, 0, 0]);
    gl.context.uniformMatrix4fv(gl.context.getUniformLocation(p.program, "mvpMatrix"), false, mvpMatrix);

    triangle = [[[0, 1, -5], [-1, -1, -5], [1, -1, -5]], [[0, 1, -5], [1, -1, -5], [1, 1, -6]]];
    mesh = new NOOGL.TriangleMesh(p, triangle);

    gl.clear();
    mesh.render(gl);
}());
